package gjw.progressbar;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

/**
 * @创建者 Jimven
 * @创建时间 2017/12/28/0028  10:34
 */
public class HorizontalProgressBarActivity extends AppCompatActivity {

    private HorizontalProgressBarWithNumber mHorizontalbar;
    private static final int MSG_PROGRESS_UPDATE = 0x110;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_horizontalprogressbar);
        initView();
        initListener();
        initData();
        initEvent();
    }

    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            int progress = mHorizontalbar.getProgress();
            mHorizontalbar.setProgress(++progress);
            if (progress > 1) {
                mHandler.removeMessages(MSG_PROGRESS_UPDATE);
            }
            mHandler.sendEmptyMessageDelayed(MSG_PROGRESS_UPDATE, 20);

        }
    };

    private void initView() {
        mHorizontalbar = (HorizontalProgressBarWithNumber) findViewById(R.id.horizontalbar);
        mHandler.sendEmptyMessage(MSG_PROGRESS_UPDATE);
    }

    private void initListener() {

    }

    private void initData() {

    }

    private void initEvent() {

    }
}
